package ru.sgu.diploma.practic;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;
import ru.sgu.diploma.practic.errors.ApplicationConfigurationException;
import ru.sgu.diploma.practic.errors.FatalException;
import ru.sgu.diploma.practic.gui.MainWindow;
import ru.sgu.diploma.practic.service.Application;

/**
 * User: datmakin
 * Date: 14.03.11
 * Email: atmakin.dv@gmail.com
 */

public class Main {
    public static void main(String[] args) {
        BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("application-context.xml"));
        Application application = (Application) beanFactory.getBean("application");
        MainWindow mainWindow = (MainWindow) beanFactory.getBean("mainWindow");
        try {
            application.configurate(args);
        } catch (ApplicationConfigurationException e) {
            System.out.print(e.getMessage() + "\n");
            System.exit(0);
        }


        mainWindow.fire();

//        try {
//            application.run();
//
//        }catch (FatalException e) {
//            System.out.print(e.getMessage() + "\n");
//            System.exit(0);
//        }
    }
}
